package com.lyp.qczp.contoller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lyp.qczp.entity.Profes;
import com.lyp.qczp.service.ProfesService;

@RestController
@CrossOrigin(origins = "*")
public class ProfesContoller {
	@Autowired
	private ProfesService profesService; 
	/**
	 * 
	 * @param 
	 * @return 1位删除成功，0是删除失败
	 */
	@PostMapping("/deleteProfesById")
	public int deleteProfesById(Integer pId) {
		return profesService.deleteById(pId);
	}
	/**
	 * 分页查询机构
	 * @param page 分页参数
	 * @param rows 分页参数
	 * @return 查询的数据 
	 */
	@PostMapping("/findProfes")
	public Map<String, Object> findProfes(Integer page, Integer rows,Profes profes) {
		
		PageRequest pageable = PageRequest.of(page - 1, rows);
		Map<String, Object> findAll = profesService.findAll(pageable,profes);
		return findAll;

	}
	
	/**
	 * 增加&修改
	 * @param 
	 * @return 1成功，0失败,
	 */
	@PostMapping("/saveProfes")
	public int saveProfes(Profes profes) {
		return profesService.save(profes);
	}
}
